import requests 
from lxml import etree
from tools import MyMongo
headers={
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3766.400 QQBrowser/10.6.4163.400'
}
res=requests.get(url='http://wenda.tianya.cn/question/2e76b49cbb5aff58',headers=headers)

tree = etree.HTML(res.text)
places=tree.xpath('//span[@class="t"]/span//text()')
place_list=[]
for str1 in  places[1::]:
    place_list.append({'name':str1[:str1.find(" "):]})

with MyMongo(db='md', table='places')as c:
    c.insert_many(place_list)